/**
 * 接口统一管理
 */
import category from "./category.js";
import product from "./product.js";
import address from "./address.js";
import coupon from "./coupon.js";
import setUp from "./setUp.js";
import collection from "./collection.js";
import footprint from "./footprint.js";

import applyShop from "./applyShop";
import signIn from "./signIn";
import shop from "./shop";
import order from "./order";
import cart from "./cart";
import swiper from "./swiper";
import Housekeeping from "./Housekeeping";
import notice from "./notice";
import login from "./login";
import message from "./message.js";

import exam from "./exam.js";


import Maker from "./Maker.js";

const apiAll = [
    address,
    product,
    category,
    coupon,
    setUp,
    collection,
    footprint,

    applyShop,
    signIn,
    shop,
    cart,
    order,
    swiper,
    Housekeeping,
    notice,
    message,
    login,
    exam,

    Maker

]

// 判断接口是否已存在
function isKeyQepeat (arr) {
    let keyArr = [], apiObj = {};
    arr.forEach((item) => {
        keyArr.push(...Object.keys(item))
        Object.assign(apiObj, item)
    })
    try {
        keyArr.forEach((item, i, arr) => {
            if (arr.indexOf(item) !== i) {
                throw new Error(`接口 key 重复项: ${item}`)
            }
        })
    } catch (error) {
        console.error('[WRH warn]:', error);
        return null
    }
    return apiObj
}
const apiDesc = isKeyQepeat(apiAll)
//进行统一导出 
export default {
    ...apiDesc
}